<?php
/*
Simple oracle query with php by zaizarul
*/

///////////////////////////////////////
/* SELECT
	$query = "oracle select statment";
	$db->db_assoc($query);		
	while($rows=$db->db_array()){
		echo "output";
	}
*/
class myoracle {
	
	var $conn;
	var $dbname;
	var $user;
	var $pass;

	
	function myoracle() {
                $ci = &get_instance();
                $usr=$ci->config->item("oracle_user");
                $pwd=$ci->config->item("oracle_pass");
                $db=$ci->config->item("oracle_dbname");
		$this->dbname = $db;
		$this->user = $usr;
		$this->pass = $pwd;
		$this->db_connect();
	}
	
	function db_connect(){
		$this->conn = oci_connect("$this->user", "$this->pass", "$this->dbname");
		if ( !$this->conn ) {
    							echo "Unable to connect: " . var_dump( OCIError() );
    							die();
							}
	}
	
	function db_close(){
		ocilogoff($this->conn);
	}
	
	function db_select($query){
		$exe = $this->db_query($query);
	  	@ociexecute($exe);
		$rows =	@oci_fetch_array($exe);
		return $rows;
	}

	function db_assoc($query){
		$this->result = $this->db_query($query);
		@ociexecute($this->result);
	}

	function db_array(){
	  	$rows =	@oci_fetch_assoc($this->result);
		return $rows;
	}
	

	function db_query($query){
		$q = @ociparse($this->conn , $query);
		return $q;
	}
	

}//end class ORACLE
?>
